#!/bin/bash

currentDir=${PWD}
echo "currentDir=" ${currentDir}

current_basedir=$(basename $currentDir)
echo "current_basedir=" ${current_basedir}

ELFNAME=".elf"
ELFNAME=${current_basedir}${ELFNAME}
echo "ELFNAME=" ${ELFNAME}

if [ -e ${ELFNAME} ]; then
    rm ${ELFNAME}
fi

make clean;make
# 使用nvidia-smi获取GPU数量
num_gpus=$(nvidia-smi -L | grep -c "UUID")
echo "Number of GPUs: $num_gpus"

#NCCL_DEBUG=INFO NCCL_LOG_INFO=NCCL_INIT ./$ELFNAME $num_gpus
#NCCL_LOG_INFO=NCCL_INIT ./$ELFNAME $num_gpus
#NCCL_DEBUG=INFO ./$ELFNAME $num_gpus
./$ELFNAME $num_gpus